<template>
  <div class="maintenance-container">
    <div class="maintenance-content">
      <div class="maintenance-icon">
        <el-icon :size="120"><Tools /></el-icon>
      </div>
      <h1 class="maintenance-title">系统维护中</h1>
      <p class="maintenance-description">
        系统正在进行维护升级，给您带来不便，敬请谅解
      </p>
      <p class="maintenance-time">
        预计维护时间：{{ maintenanceTime || '待定' }}
      </p>
      <div class="maintenance-actions">
        <el-button type="primary" size="large" @click="goToLogin">
          返回登录页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Tools } from '@element-plus/icons-vue';
import axios from 'axios';

export default {
  name: 'Maintenance',
  components: {
    Tools
  },
  data() {
    return {
      maintenanceTime: ''
    };
  },
  mounted() {
    this.loadMaintenanceInfo();
  },
  methods: {
    async loadMaintenanceInfo() {
      try {
        // 尝试获取维护时间设置
        const res = await axios.get('http://localhost:8080/api/admin/system-setting/key/maintenance_time');
        if (res.data.code === 200 && res.data.data) {
          this.maintenanceTime = res.data.data.settingValue || '待定';
        }
      } catch (error) {
        console.error('获取维护信息失败:', error);
      }
    },
    goToLogin() {
      this.$router.push('/login');
    }
  }
};
</script>

<style scoped>
.maintenance-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.maintenance-content {
  text-align: center;
  background: white;
  border-radius: 20px;
  padding: 60px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 100%;
}

.maintenance-icon {
  margin-bottom: 30px;
  color: #409eff;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.maintenance-title {
  font-size: 36px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 20px 0;
}

.maintenance-description {
  font-size: 16px;
  color: #606266;
  margin: 0 0 30px 0;
  line-height: 1.6;
}

.maintenance-time {
  font-size: 14px;
  color: #909399;
  margin: 0 0 40px 0;
}

.maintenance-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

@media (max-width: 768px) {
  .maintenance-content {
    padding: 40px 20px;
  }

  .maintenance-title {
    font-size: 28px;
  }

  .maintenance-icon {
    margin-bottom: 20px;
  }

  .maintenance-icon .el-icon {
    font-size: 80px !important;
  }
}
</style>

